<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>---回调---</title>
  <script src="plugins/vue/dist/vue.js"></script>
  <script src="plugins/axios/dist/axios.js"></script>
  <script src="script/common.js"></script>
</head>
<body>
  <div id="back">

  </div>
<script type="text/javascript">
    new Vue({
        el: "#back",
        data: {

        },
        method:{

        },
        mounted(){
            var obj=parseurl()
            console.log(obj)
            console.log("============")
            console.log(obj.code)

            this.$http.post("/wechat", obj)
                .then(result => {
                    result = result.data;
                    console.log("---wechat----")
                    console.log(result.data)
                    debugger;

                    if(result.data.msg == "success"){
                        // 说明后端已经绑定，并且已经做了免密登录
                        let {token,loginInfo} = result.data;
                        localStorage.setItem("loginUser", JSON.stringify(loginInfo));
                        localStorage.setItem("token", token);
                        location.href = "/index.html";
                    }else{
                        // 说明该微信用户还没有绑定，需要跳转到绑定页面进行绑定
                        let {accessToken,openid} = result.data;
                        location.href = "/binder.html?openid="+openid+"&accessToken="+accessToken;
                    }
                }).catch(result => {
                    alert("登陆失败-"+result.message)
            })



        }
    })
</script>

</body>
</html>